<?php

namespace app\dao;

use app\model\Student;

class StudentDao extends BaseDao
{
    private $query;

    protected function setModel()
    {
        // TODO: Implement setModel() method.
        return Student::class;
    }

    public function __construct()
    {
        $this->query = new Student();
    }

    public function hiddenPassword(){
        $this->query = $this->query->hidden(['password']);
        return $this;
    }

    public function findByUsername($username){
        $this->query = $this->query->where('username' , $username);
        return $this;
    }

    public function findByPassword($password){
        $this->query = $this->query->where('password' , $password);
        return $this;
    }

    public function findById($id){
        $this->query = $this->query->where('id',$id);
        return $this;
    }
    public function getOne(){
        return $this->query->find();
    }

    public function getAll(){
        return $this->query->select();
    }

    public function getField($field){
        $this->query = $this->query->field($field);
        return $this;
    }

    public function order(Array $filed){
        $this->query =  $this->query->order($filed);
        return $this;
    }



}